package com.gangan.controller.web;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gangan.controller.common.BaseController;
import com.gangan.model.CmsContent;
import com.gangan.model.CmsWish;
import com.gangan.service.ICmsContentService;
import com.gangan.service.ICmsWishService;
import com.gangan.tools.MessageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengweicheng
 * @since 2019-09-04
 */
@Api(description = "*我的收藏模块控制层")
@RestController
@RequestMapping("/cmsWish")
public class CmsWishController extends BaseController {

    @Autowired
    ICmsWishService cmsWishService;

//    @RequestMapping(value = "/list",method = RequestMethod.GET)
//    @ApiOperation(value="内容数据列表", notes="根据相关条件查询列表数据")
//    public MessageBean list(Page page){
//        return resultSuccess(cmsWishService.page(page,Wrappers.<CmsContent>query().lambda().orderByAsc(CmsWish::getListsorder)));
//    }


    @RequestMapping(value = "/del",method = RequestMethod.POST)
    @ApiOperation(value="根据id删除点赞", notes="根据自增主键移除数据")
    public MessageBean del(Integer id){
        return resultSuccess(cmsWishService.removeById(id));
    }

    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ApiOperation(value="收藏文章和活动", notes="将提交的数据保存到数据库")
    public MessageBean add(CmsWish add){
        return resultSuccess(cmsWishService.save(add));
    }

//    @RequestMapping(value = "/edit",method = RequestMethod.POST)
//    @ApiOperation(value="编辑内容数据", notes="根据主键修改数据")
//    public MessageBean edit(CmsWish edit){
//        return resultSuccess(cmsWishService.updateById(edit));
//    }
@RequestMapping(value = "/selectCmsWishByUserId",method = RequestMethod.POST)
@ApiOperation(value="根据用户id查询用户收藏的文章", notes="查询用户收藏的文章")
public MessageBean selectUserCmsWishListPage(Page page){

    return resultSuccess(cmsWishService.selectUserListPage(page));
}
}
